package com.owbtgad.common.network

/**
 * 创建日期 2021/5/31
 * 描述：
 */

class BaseResp<T> {
    var code: Int? = -1
    var msg: String? = ""
    var data: T? = null
        private set
    var dataState: DataState? = null
    var subCode: Int? = 0
    var subMsg: String? = null
    var error: Throwable? = null
    fun isOk(): Boolean {
        return code == 0
    }

    fun getUrlCode(): Int? = if (subCode == 0) code else subCode
    fun getUrlMsg(): String? = if (subMsg?.isNotEmpty() == true) subMsg else msg
}

enum class DataState {
    STATE_CREATE,//创建
    STATE_LOADING,//加载中
    STATE_SUCCESS,//成功
    STATE_COMPLETED,//完成
    STATE_EMPTY,//数据为null
    STATE_FAILED,//接口请求成功但是服务器返回error
    STATE_ERROR,//请求失败
    STATE_UNKNOWN//未知
}